{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Height Diameter Modeling\n",
    "\n",
    "For this first example, we'll walk through installing the package,\n",
    "loading some included data and then we'll compare 2 sets of coefficients\n",
    "for a height diameter model.\n",
    "\n",
    "Height-diameter models are common throughout forestry and many different forms\n",
    "have been developed and parametrized. ForestBiometrics simplifies working with\n",
    "these by 1. Cataloging a variety of widely used model forms in ready to use form\n",
    "and 2. by allowing a user to quickly and easily change both model form and coefficent sets.\n",
    "\n",
    "[The documentation](https://crghilardi.github.io/ForestBiometrics.jl/latest/functionality/height_diameter.html) explains how this is done in a bit more detail,\n",
    "but for now we'll gloss over those details and work through an example.\n",
    "\n",
    "\n",
    "Installing package\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#Pkg.add(\"ForestBiometrics\") #if install needed\n",
    "using ForestBiometrics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next let's add some data included with the package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>_Stand_CN</th><th>Stand_ID</th><th>StandPlot_CN</th><th>StandPlot_ID</th><th>Plot_ID</th><th>Tree_ID</th><th>Tree_Count</th><th>History</th><th>Species</th><th>DBH</th><th>DG</th><th>Ht</th><th>HTG</th><th>HtTopK</th><th>CrRatio</th><th>Damage1</th><th>Severity1</th><th>Damage2</th><th>Severity2</th><th>Damage3</th><th>Severity3</th><th>TreeValue</th><th>Prescription</th><th>Age</th><th>Slope</th><th>Aspect</th><th>PV_Code</th><th>TopoCode</th><th>SitePrep</th></tr></thead><tbody><tr><th>1</th><td>212681010354</td><td>1160805020003</td><td>212681010354_1</td><td>01160805020003_1</td><td>1</td><td>1</td><td>6.10918</td><td>1</td><td>PP</td><td>24.5</td><td>1.2</td><td>81</td><td>NA</td><td>NA</td><td>45</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>41</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>2</th><td>212681010354</td><td>1160805020003</td><td>212681010354_1</td><td>01160805020003_1</td><td>1</td><td>2</td><td>20.31597</td><td>6</td><td>PP</td><td>9.5</td><td>NA</td><td>42</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>41</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>3</th><td>212681010354</td><td>1160805020003</td><td>212681010354_1</td><td>01160805020003_1</td><td>1</td><td>3</td><td>300.0</td><td>1</td><td>PP</td><td>2.1</td><td>NA</td><td>10</td><td>0.8</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>41</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>4</th><td>212681010354</td><td>1160805020003</td><td>212681010354_1</td><td>01160805020003_1</td><td>1</td><td>4</td><td>300.0</td><td>1</td><td>PP</td><td>2.2</td><td>NA</td><td>14</td><td>0.5</td><td>NA</td><td>40</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>41</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>5</th><td>212681010354</td><td>1160805020003</td><td>212681010354_2</td><td>01160805020003_2</td><td>2</td><td>5</td><td>25.8953</td><td>1</td><td>PP</td><td>11.9</td><td>2.5</td><td>41</td><td>NA</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>60</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>6</th><td>212681010354</td><td>1160805020003</td><td>212681010354_2</td><td>01160805020003_2</td><td>2</td><td>6</td><td>21.69842</td><td>1</td><td>PP</td><td>13.0</td><td>NA</td><td>52</td><td>NA</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>60</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>7</th><td>212681010354</td><td>1160805020003</td><td>212681010354_2</td><td>01160805020003_2</td><td>2</td><td>7</td><td>300.0</td><td>1</td><td>DF</td><td>0.1</td><td>NA</td><td>4</td><td>0.8</td><td>NA</td><td>90</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>60</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>8</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>8</td><td>116.93346</td><td>1</td><td>PP</td><td>5.6</td><td>1.3</td><td>28</td><td>NA</td><td>NA</td><td>25</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>9</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>9</td><td>12.8393</td><td>1</td><td>PP</td><td>16.9</td><td>1.4</td><td>80</td><td>NA</td><td>NA</td><td>50</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>10</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>10</td><td>11.318</td><td>1</td><td>PP</td><td>18.0</td><td>1.1</td><td>73</td><td>NA</td><td>NA</td><td>60</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>11</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>11</td><td>15.06835</td><td>1</td><td>PP</td><td>15.6</td><td>NA</td><td>68</td><td>NA</td><td>NA</td><td>45</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>12</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>12</td><td>16.96994</td><td>1</td><td>DF</td><td>14.7</td><td>0.9</td><td>66</td><td>NA</td><td>NA</td><td>50</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>13</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>13</td><td>57.2974</td><td>9</td><td>DF</td><td>8.0</td><td>NA</td><td>8</td><td>NA</td><td>8</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>14</th><td>212681010354</td><td>1160805020003</td><td>212681010354_3</td><td>01160805020003_3</td><td>3</td><td>14</td><td>8.81159</td><td>1</td><td>DF</td><td>20.4</td><td>1.2</td><td>83</td><td>NA</td><td>NA</td><td>40</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>66</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>15</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>15</td><td>16.96994</td><td>1</td><td>PP</td><td>14.7</td><td>1.0</td><td>87</td><td>NA</td><td>NA</td><td>25</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>16</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>16</td><td>6.69704</td><td>1</td><td>DF</td><td>23.4</td><td>1.1</td><td>96</td><td>NA</td><td>NA</td><td>40</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>17</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>17</td><td>11.07062</td><td>1</td><td>PP</td><td>18.2</td><td>1.0</td><td>78</td><td>NA</td><td>NA</td><td>20</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>18</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>18</td><td>24.23844</td><td>1</td><td>PP</td><td>12.3</td><td>NA</td><td>65</td><td>NA</td><td>NA</td><td>20</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>19</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>19</td><td>6.75465</td><td>1</td><td>DF</td><td>23.3</td><td>NA</td><td>108</td><td>NA</td><td>NA</td><td>50</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>20</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>20</td><td>44.28249</td><td>1</td><td>PP</td><td>9.1</td><td>NA</td><td>47</td><td>NA</td><td>NA</td><td>40</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>21</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>21</td><td>300.0</td><td>1</td><td>DF</td><td>0.1</td><td>NA</td><td>3</td><td>0.4</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>22</th><td>212681010354</td><td>1160805020003</td><td>212681010354_4</td><td>01160805020003_4</td><td>4</td><td>22</td><td>1500.0</td><td>1</td><td>DF</td><td>0.1</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>63</td><td>100</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>23</th><td>212681010354</td><td>1160805020003</td><td>212681010354_5</td><td>01160805020003_5</td><td>5</td><td>23</td><td>2.93363</td><td>7</td><td>DF</td><td>25.0</td><td>NA</td><td>50</td><td>NA</td><td>50</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>68</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>24</th><td>212681010354</td><td>1160805020003</td><td>212681010354_5</td><td>01160805020003_5</td><td>5</td><td>24</td><td>6.31365</td><td>1</td><td>DF</td><td>24.1</td><td>0.7</td><td>85</td><td>NA</td><td>NA</td><td>55</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>68</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>25</th><td>212681010354</td><td>1160805020003</td><td>212681010354_5</td><td>01160805020003_5</td><td>5</td><td>25</td><td>4.15721</td><td>1</td><td>PP</td><td>29.7</td><td>1.0</td><td>88</td><td>NA</td><td>NA</td><td>40</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>2</td><td>NA</td><td>NA</td><td>68</td><td>140</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>26</th><td>212681010354</td><td>1160805020003</td><td>212681010354_6</td><td>01160805020003_6</td><td>6</td><td>26</td><td>21.36841</td><td>1</td><td>PP</td><td>13.1</td><td>0.8</td><td>52</td><td>NA</td><td>NA</td><td>85</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>74</td><td>120</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>27</th><td>212681010354</td><td>1160805020003</td><td>212681010354_6</td><td>01160805020003_6</td><td>6</td><td>27</td><td>6.10918</td><td>1</td><td>PP</td><td>24.5</td><td>0.5</td><td>69</td><td>NA</td><td>NA</td><td>80</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>74</td><td>120</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>28</th><td>212681010354</td><td>1160805020003</td><td>212681010354_6</td><td>01160805020003_6</td><td>6</td><td>28</td><td>4.45196</td><td>1</td><td>PP</td><td>28.7</td><td>1.0</td><td>78</td><td>NA</td><td>NA</td><td>70</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>74</td><td>120</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>29</th><td>212681010354</td><td>1160805020003</td><td>212681010354_7</td><td>01160805020003_7</td><td>7</td><td>29</td><td>8.47595</td><td>1</td><td>DF</td><td>20.8</td><td>0.8</td><td>78</td><td>NA</td><td>NA</td><td>60</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>1</td><td>NA</td><td>NA</td><td>75</td><td>120</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>30</th><td>212681010354</td><td>1160805020003</td><td>212681010354_7</td><td>01160805020003_7</td><td>7</td><td>30</td><td>20.42233</td><td>1</td><td>DF</td><td>13.4</td><td>0.9</td><td>49</td><td>NA</td><td>NA</td><td>45</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>NA</td><td>3</td><td>NA</td><td>NA</td><td>75</td><td>120</td><td>260</td><td>NA</td><td>NA</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/plain": [
       "34×29 DataFrames.DataFrame\n",
       "│ Row │ _Stand_CN    │ Stand_ID      │ StandPlot_CN     │ StandPlot_ID       │\n",
       "├─────┼──────────────┼───────────────┼──────────────────┼────────────────────┤\n",
       "│ 1   │ 212681010354 │ 1160805020003 │ \"212681010354_1\" │ \"01160805020003_1\" │\n",
       "│ 2   │ 212681010354 │ 1160805020003 │ \"212681010354_1\" │ \"01160805020003_1\" │\n",
       "│ 3   │ 212681010354 │ 1160805020003 │ \"212681010354_1\" │ \"01160805020003_1\" │\n",
       "│ 4   │ 212681010354 │ 1160805020003 │ \"212681010354_1\" │ \"01160805020003_1\" │\n",
       "│ 5   │ 212681010354 │ 1160805020003 │ \"212681010354_2\" │ \"01160805020003_2\" │\n",
       "│ 6   │ 212681010354 │ 1160805020003 │ \"212681010354_2\" │ \"01160805020003_2\" │\n",
       "│ 7   │ 212681010354 │ 1160805020003 │ \"212681010354_2\" │ \"01160805020003_2\" │\n",
       "│ 8   │ 212681010354 │ 1160805020003 │ \"212681010354_3\" │ \"01160805020003_3\" │\n",
       "│ 9   │ 212681010354 │ 1160805020003 │ \"212681010354_3\" │ \"01160805020003_3\" │\n",
       "│ 10  │ 212681010354 │ 1160805020003 │ \"212681010354_3\" │ \"01160805020003_3\" │\n",
       "│ 11  │ 212681010354 │ 1160805020003 │ \"212681010354_3\" │ \"01160805020003_3\" │\n",
       "⋮\n",
       "│ 23  │ 212681010354 │ 1160805020003 │ \"212681010354_5\" │ \"01160805020003_5\" │\n",
       "│ 24  │ 212681010354 │ 1160805020003 │ \"212681010354_5\" │ \"01160805020003_5\" │\n",
       "│ 25  │ 212681010354 │ 1160805020003 │ \"212681010354_5\" │ \"01160805020003_5\" │\n",
       "│ 26  │ 212681010354 │ 1160805020003 │ \"212681010354_6\" │ \"01160805020003_6\" │\n",
       "│ 27  │ 212681010354 │ 1160805020003 │ \"212681010354_6\" │ \"01160805020003_6\" │\n",
       "│ 28  │ 212681010354 │ 1160805020003 │ \"212681010354_6\" │ \"01160805020003_6\" │\n",
       "│ 29  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "│ 30  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "│ 31  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "│ 32  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "│ 33  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "│ 34  │ 212681010354 │ 1160805020003 │ \"212681010354_7\" │ \"01160805020003_7\" │\n",
       "\n",
       "│ Row │ Plot_ID │ Tree_ID │ Tree_Count │ History │ Species │ DBH  │ DG  │ Ht │\n",
       "├─────┼─────────┼─────────┼────────────┼─────────┼─────────┼──────┼─────┼────┤\n",
       "│ 1   │ 1       │ 1       │ 6.10918    │ 1       │ \"PP\"    │ 24.5 │ 1.2 │ 81 │\n",
       "│ 2   │ 1       │ 2       │ 20.316     │ 6       │ \"PP\"    │ 9.5  │ NA  │ 42 │\n",
       "│ 3   │ 1       │ 3       │ 300.0      │ 1       │ \"PP\"    │ 2.1  │ NA  │ 10 │\n",
       "│ 4   │ 1       │ 4       │ 300.0      │ 1       │ \"PP\"    │ 2.2  │ NA  │ 14 │\n",
       "│ 5   │ 2       │ 5       │ 25.8953    │ 1       │ \"PP\"    │ 11.9 │ 2.5 │ 41 │\n",
       "│ 6   │ 2       │ 6       │ 21.6984    │ 1       │ \"PP\"    │ 13.0 │ NA  │ 52 │\n",
       "│ 7   │ 2       │ 7       │ 300.0      │ 1       │ \"DF\"    │ 0.1  │ NA  │ 4  │\n",
       "│ 8   │ 3       │ 8       │ 116.933    │ 1       │ \"PP\"    │ 5.6  │ 1.3 │ 28 │\n",
       "│ 9   │ 3       │ 9       │ 12.8393    │ 1       │ \"PP\"    │ 16.9 │ 1.4 │ 80 │\n",
       "│ 10  │ 3       │ 10      │ 11.318     │ 1       │ \"PP\"    │ 18.0 │ 1.1 │ 73 │\n",
       "│ 11  │ 3       │ 11      │ 15.0684    │ 1       │ \"PP\"    │ 15.6 │ NA  │ 68 │\n",
       "⋮\n",
       "│ 23  │ 5       │ 23      │ 2.93363    │ 7       │ \"DF\"    │ 25.0 │ NA  │ 50 │\n",
       "│ 24  │ 5       │ 24      │ 6.31365    │ 1       │ \"DF\"    │ 24.1 │ 0.7 │ 85 │\n",
       "│ 25  │ 5       │ 25      │ 4.15721    │ 1       │ \"PP\"    │ 29.7 │ 1.0 │ 88 │\n",
       "│ 26  │ 6       │ 26      │ 21.3684    │ 1       │ \"PP\"    │ 13.1 │ 0.8 │ 52 │\n",
       "│ 27  │ 6       │ 27      │ 6.10918    │ 1       │ \"PP\"    │ 24.5 │ 0.5 │ 69 │\n",
       "│ 28  │ 6       │ 28      │ 4.45196    │ 1       │ \"PP\"    │ 28.7 │ 1.0 │ 78 │\n",
       "│ 29  │ 7       │ 29      │ 8.47595    │ 1       │ \"DF\"    │ 20.8 │ 0.8 │ 78 │\n",
       "│ 30  │ 7       │ 30      │ 20.4223    │ 1       │ \"DF\"    │ 13.4 │ 0.9 │ 49 │\n",
       "│ 31  │ 7       │ 31      │ 19.5377    │ 1       │ \"DF\"    │ 13.7 │ NA  │ 55 │\n",
       "│ 32  │ 7       │ 32      │ 22.3818    │ 1       │ \"DF\"    │ 12.8 │ NA  │ 54 │\n",
       "│ 33  │ 7       │ 33      │ 8.47595    │ 1       │ \"DF\"    │ 20.8 │ NA  │ 81 │\n",
       "│ 34  │ 7       │ 34      │ 13.1487    │ 1       │ \"DF\"    │ 16.7 │ NA  │ 78 │\n",
       "\n",
       "│ Row │ HTG │ HtTopK │ CrRatio │ Damage1 │ Severity1 │ Damage2 │ Severity2 │\n",
       "├─────┼─────┼────────┼─────────┼─────────┼───────────┼─────────┼───────────┤\n",
       "│ 1   │ NA  │ NA     │ 45      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 2   │ NA  │ NA     │ NA      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 3   │ 0.8 │ NA     │ 80      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 4   │ 0.5 │ NA     │ 40      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 5   │ NA  │ NA     │ 80      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 6   │ NA  │ NA     │ 80      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 7   │ 0.8 │ NA     │ 90      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 8   │ NA  │ NA     │ 25      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 9   │ NA  │ NA     │ 50      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 10  │ NA  │ NA     │ 60      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 11  │ NA  │ NA     │ 45      │ NA      │ NA        │ NA      │ NA        │\n",
       "⋮\n",
       "│ 23  │ NA  │ 50     │ NA      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 24  │ NA  │ NA     │ 55      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 25  │ NA  │ NA     │ 40      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 26  │ NA  │ NA     │ 85      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 27  │ NA  │ NA     │ 80      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 28  │ NA  │ NA     │ 70      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 29  │ NA  │ NA     │ 60      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 30  │ NA  │ NA     │ 45      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 31  │ NA  │ NA     │ 35      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 32  │ NA  │ NA     │ 35      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 33  │ NA  │ NA     │ 60      │ NA      │ NA        │ NA      │ NA        │\n",
       "│ 34  │ NA  │ NA     │ 60      │ NA      │ NA        │ NA      │ NA        │\n",
       "\n",
       "│ Row │ Damage3 │ Severity3 │ TreeValue │ Prescription │ Age │ Slope │ Aspect │\n",
       "├─────┼─────────┼───────────┼───────────┼──────────────┼─────┼───────┼────────┤\n",
       "│ 1   │ NA      │ NA        │ 1         │ NA           │ NA  │ 41    │ 140    │\n",
       "│ 2   │ NA      │ NA        │ 2         │ NA           │ NA  │ 41    │ 140    │\n",
       "│ 3   │ NA      │ NA        │ 3         │ NA           │ NA  │ 41    │ 140    │\n",
       "│ 4   │ NA      │ NA        │ 1         │ NA           │ NA  │ 41    │ 140    │\n",
       "│ 5   │ NA      │ NA        │ 3         │ NA           │ NA  │ 60    │ 140    │\n",
       "│ 6   │ NA      │ NA        │ 3         │ NA           │ NA  │ 60    │ 140    │\n",
       "│ 7   │ NA      │ NA        │ 1         │ NA           │ NA  │ 60    │ 140    │\n",
       "│ 8   │ NA      │ NA        │ 1         │ NA           │ NA  │ 66    │ 140    │\n",
       "│ 9   │ NA      │ NA        │ 2         │ NA           │ NA  │ 66    │ 140    │\n",
       "│ 10  │ NA      │ NA        │ 3         │ NA           │ NA  │ 66    │ 140    │\n",
       "│ 11  │ NA      │ NA        │ 2         │ NA           │ NA  │ 66    │ 140    │\n",
       "⋮\n",
       "│ 23  │ NA      │ NA        │ 3         │ NA           │ NA  │ 68    │ 140    │\n",
       "│ 24  │ NA      │ NA        │ 2         │ NA           │ NA  │ 68    │ 140    │\n",
       "│ 25  │ NA      │ NA        │ 2         │ NA           │ NA  │ 68    │ 140    │\n",
       "│ 26  │ NA      │ NA        │ 1         │ NA           │ NA  │ 74    │ 120    │\n",
       "│ 27  │ NA      │ NA        │ 3         │ NA           │ NA  │ 74    │ 120    │\n",
       "│ 28  │ NA      │ NA        │ 3         │ NA           │ NA  │ 74    │ 120    │\n",
       "│ 29  │ NA      │ NA        │ 1         │ NA           │ NA  │ 75    │ 120    │\n",
       "│ 30  │ NA      │ NA        │ 3         │ NA           │ NA  │ 75    │ 120    │\n",
       "│ 31  │ NA      │ NA        │ 1         │ NA           │ NA  │ 75    │ 120    │\n",
       "│ 32  │ NA      │ NA        │ 2         │ NA           │ NA  │ 75    │ 120    │\n",
       "│ 33  │ NA      │ NA        │ 2         │ NA           │ NA  │ 75    │ 120    │\n",
       "│ 34  │ NA      │ NA        │ 3         │ NA           │ NA  │ 75    │ 120    │\n",
       "\n",
       "│ Row │ PV_Code │ TopoCode │ SitePrep │\n",
       "├─────┼─────────┼──────────┼──────────┤\n",
       "│ 1   │ 260     │ NA       │ NA       │\n",
       "│ 2   │ 260     │ NA       │ NA       │\n",
       "│ 3   │ 260     │ NA       │ NA       │\n",
       "│ 4   │ 260     │ NA       │ NA       │\n",
       "│ 5   │ 260     │ NA       │ NA       │\n",
       "│ 6   │ 260     │ NA       │ NA       │\n",
       "│ 7   │ 260     │ NA       │ NA       │\n",
       "│ 8   │ 260     │ NA       │ NA       │\n",
       "│ 9   │ 260     │ NA       │ NA       │\n",
       "│ 10  │ 260     │ NA       │ NA       │\n",
       "│ 11  │ 260     │ NA       │ NA       │\n",
       "⋮\n",
       "│ 23  │ 260     │ NA       │ NA       │\n",
       "│ 24  │ 260     │ NA       │ NA       │\n",
       "│ 25  │ 260     │ NA       │ NA       │\n",
       "│ 26  │ 260     │ NA       │ NA       │\n",
       "│ 27  │ 260     │ NA       │ NA       │\n",
       "│ 28  │ 260     │ NA       │ NA       │\n",
       "│ 29  │ 260     │ NA       │ NA       │\n",
       "│ 30  │ 260     │ NA       │ NA       │\n",
       "│ 31  │ 260     │ NA       │ NA       │\n",
       "│ 32  │ 260     │ NA       │ NA       │\n",
       "│ 33  │ 260     │ NA       │ NA       │\n",
       "│ 34  │ 260     │ NA       │ NA       │"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datapath = Pkg.dir(\"ForestBiometrics\", \"test\", \"data\")\n",
    "using DataFrames\n",
    "df=readtable(joinpath(datapath, \"IEsubset_Data_CSV.csv\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem Statement\n",
    "Consider a user debating between two variants of FVS, the [Inland Empire Variant](https://www.fs.fed.us/fmsc/ftp/fvs/docs/overviews/FVSie_Overview.pdf)\n",
    "or the smaller [Kootenai variant](https://www.fs.fed.us/fmsc/ftp/fvs/docs/overviews/FVSkt_Overview.pdf)\n",
    "\n",
    "Both of these have default behavior that will assign height information to tree records if none are given.\n",
    "They both use the Wyckoff model form, but have different coefficient sets for species.\n",
    "Ignoring the FVS internal model fitting functionality if some but not all heights are given, a user may wonder\n",
    "what the impact of these similar but different model formulations may have.\n",
    "\n",
    "\n",
    "# Using the package\n",
    "\n",
    "First we need to assemble ```HeightDiameter``` types for both variants with both the Wyckoff model form and coefficient sets.\n",
    "\n",
    "ForestBiometrics uses a ```String => Array``` dictionary in combination with a\n",
    "```HeightDiameter``` type to accommodate model forms with ```1``` through ```N``` coefficients.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Dict{String,Array{Float64,N} where N} with 23 entries:\n",
       "  \"ES\" => [4.9219 -8.30289]\n",
       "  \"AS\" => [4.4421 -6.5405]\n",
       "  \"LP\" => [4.62171 -5.32481]\n",
       "  \"WB\" => [4.97407 -6.78347]\n",
       "  \"AF\" => [4.76537 -7.61062]\n",
       "  \"PP\" => [4.9288 -9.32795]\n",
       "  \"OS\" => [4.77951 -9.31743]\n",
       "  \"RM\" => [3.2 -5.0]\n",
       "  \"PY\" => [4.192 -5.1651]\n",
       "  \"MM\" => [4.4421 -6.5405]\n",
       "  \"GF\" => [5.00233 -8.19365]\n",
       "  \"WP\" => [5.19988 -9.26718]\n",
       "  \"RC\" => [4.89564 -8.39057]\n",
       "  \"DF\" => [4.81519 -7.29306]\n",
       "  \"CO\" => [4.4421 -6.5405]\n",
       "  \"LL\" => [4.76537 -7.61062]\n",
       "  \"PI\" => [3.2 -5.0]\n",
       "  \"OH\" => [4.4421 -6.5405]\n",
       "  \"PB\" => [4.4421 -6.5405]\n",
       "  \"WL\" => [4.97407 -6.78347]\n",
       "  \"MH\" => [4.77951 -9.31743]\n",
       "  \"LM\" => [4.192 -5.1651]\n",
       "  \"WH\" => [4.97331 -8.1973]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#I have the full species list in these, but the example\n",
    "#data does not include records of all these species.\n",
    "\n",
    "#First, the Kootenai Variant\n",
    "\n",
    "FVS_KT=Dict{String,Array{Float64}}(\n",
    "\"WP\" => [5.1868 -10.4219],\n",
    "\"WL\" => [5.0545 -8.6187],\n",
    "\"DF\" => [4.8768 -9.1467],\n",
    "\"GF\" => [5.0639 -9.8924],\n",
    "\"WH\" => [4.9273 -8.7275],\n",
    "\"RC\" => [4.8813 -9.6285],\n",
    "\"LP\" => [4.7778 -6.3364],\n",
    "\"ES\" => [5.0796 -10.2015],\n",
    "\"AF\" => [4.9301 -8.8252],\n",
    "\"PP\" => [5.0199 -12.0148],\n",
    "\"OT\" => [4.7795 -9.3174]\n",
    ")\n",
    "\n",
    "#Now the Inland Empire variant\n",
    "\n",
    "FVS_IE=Dict{String,Array{Float64}}(\n",
    "\"WP\"=>[5.19988 -9.26718],\n",
    "\"WL\"=>[4.97407 -6.78347],\n",
    "\"DF\"=>[4.81519 -7.29306],\n",
    "\"GF\"=>[5.00233 -8.19365],\n",
    "\"WH\"=>[4.97331 -8.19730],\n",
    "\"RC\"=>[4.89564 -8.39057],\n",
    "\"LP\"=>[4.62171 -5.32481],\n",
    "\"ES\"=>[4.9219 -8.30289],\n",
    "\"AF\"=>[4.76537 -7.61062],\n",
    "\"PP\"=>[4.9288 -9.32795],\n",
    "\"MH\"=>[4.77951 -9.31743],\n",
    "\"WB\"=>[4.97407 -6.78347],\n",
    "\"LM\"=>[4.19200 -5.16510],\n",
    "\"LL\"=>[4.76537 -7.61062],\n",
    "\"PI\"=>[3.20000 -5.00000],\n",
    "\"RM\"=>[3.20000 -5.00000],\n",
    "\"PY\"=>[4.19200 -5.16510],\n",
    "\"AS\"=>[4.44210 -6.54050],\n",
    "\"CO\"=>[4.44210 -6.54050],\n",
    "\"MM\"=>[4.44210 -6.54050],\n",
    "\"PB\"=>[4.44210 -6.54050],\n",
    "\"OH\"=>[4.44210 -6.54050],\n",
    "\"OS\"=>[4.77951 -9.31743]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "Wyckoff is a pre-formulated model form included in the package, if we run just Wyckoff we can see\n",
    "it returns an anonymous function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(::#27) (generic function with 1 method)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Wyckoff"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So we can now build the type with the dictionaries above and the model form."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(::HeightDiameter) (generic function with 0 methods)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Build a HeightDiameter type with the Wyckoff model form\n",
    "#and the respective coefficent sets\n",
    "\n",
    "IE_hts = HeightDiameter(Wyckoff,FVS_IE)\n",
    "KT_hts = HeightDiameter(Wyckoff,FVS_KT)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "We can then pass that to the ```calculate_height()``` function which along with designating the columns for species and DBH\n",
    "will calculate the height for that tree record.\n",
    "No extra if statements are needed to account for species, since that is achieved internally by the function\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34-element Array{Float64,1}:\n",
       "  99.0124 \n",
       "  52.7132 \n",
       "   7.6398 \n",
       "   8.04407\n",
       "  64.1516 \n",
       "  68.6805 \n",
       "   4.53212\n",
       "  29.0197 \n",
       "  81.8764 \n",
       "  84.9425 \n",
       "  77.9142 \n",
       "  77.7741 \n",
       "  51.9891 \n",
       "   ⋮      \n",
       "  96.7963 \n",
       "  95.6393 \n",
       " 106.864  \n",
       "  69.0724 \n",
       "  99.0124 \n",
       " 105.524  \n",
       "  90.748  \n",
       "  74.0199 \n",
       "  74.9269 \n",
       "  72.1262 \n",
       "  90.748  \n",
       "  82.7601 "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:pred_htIE]=[calculate_height(IE_hts,df[:DBH][i],df[:Species][i]) for i in 1:size(df,1)]\n",
    "df[:pred_htKT]=[calculate_height(KT_hts,df[:DBH][i],df[:Species][i]) for i in 1:size(df,1)]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once that's done, we can plot the results and see the difference\n",
    "between the two parameter sets for the same model form.\n",
    "\n",
    "The single stand in the example data only has Douglas-Fir and Ponderosa Pine records,\n",
    "but we can see that the Kootenai variant would underestimate heights relative to the\n",
    "IE variant."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip1200\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip1200)\" points=\"\n",
       "0,400 600,400 600,0 0,0 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip1201\">\n",
       "    <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip1200)\" points=\"\n",
       "51.265,360.065 580.315,360.065 580.315,11.811 51.265,11.811 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip1202\">\n",
       "    <rect x=\"51\" y=\"11\" width=\"530\" height=\"349\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  53.6471,360.065 53.6471,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  171.896,360.065 171.896,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  290.145,360.065 290.145,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  408.394,360.065 408.394,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  526.643,360.065 526.643,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  51.265,358.497 580.315,358.497 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  51.265,280.658 580.315,280.658 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  51.265,202.819 580.315,202.819 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  51.265,124.98 580.315,124.98 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  51.265,47.1414 580.315,47.1414 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,360.065 580.315,360.065 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,360.065 51.265,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  53.6471,360.065 53.6471,354.842 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  171.896,360.065 171.896,354.842 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  290.145,360.065 290.145,354.842 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  408.394,360.065 408.394,354.842 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  526.643,360.065 526.643,354.842 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,358.497 59.2007,358.497 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,280.658 59.2007,280.658 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,202.819 59.2007,202.819 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,124.98 59.2007,124.98 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  51.265,47.1414 59.2007,47.1414 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 53.6471, 373.865)\" x=\"53.6471\" y=\"373.865\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 171.896, 373.865)\" x=\"171.896\" y=\"373.865\">25</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 290.145, 373.865)\" x=\"290.145\" y=\"373.865\">50</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 408.394, 373.865)\" x=\"408.394\" y=\"373.865\">75</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 526.643, 373.865)\" x=\"526.643\" y=\"373.865\">100</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 45.265, 362.997)\" x=\"45.265\" y=\"362.997\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 45.265, 285.158)\" x=\"45.265\" y=\"285.158\">25</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 45.265, 207.319)\" x=\"45.265\" y=\"207.319\">50</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 45.265, 129.48)\" x=\"45.265\" y=\"129.48\">75</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 45.265, 51.6414)\" x=\"45.265\" y=\"51.6414\">100</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:16; text-anchor:middle;\" transform=\"rotate(0, 315.79, 397.6)\" x=\"315.79\" y=\"397.6\">Predicted Height - IE</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:16; text-anchor:middle;\" transform=\"rotate(-90, 14.4, 185.938)\" x=\"14.4\" y=\"185.938\">Predicted Height - KT</text>\n",
       "</g>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"441.645\" cy=\"116.343\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"441.645\" cy=\"116.343\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"334.434\" cy=\"196.626\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"334.434\" cy=\"196.626\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"489.945\" cy=\"78.0459\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"489.945\" cy=\"78.0459\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"507.704\" cy=\"63.6697\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"507.704\" cy=\"63.6697\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"507.172\" cy=\"64.1026\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"507.172\" cy=\"64.1026\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"75.7022\" cy=\"344.386\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"515.738\" cy=\"57.1163\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"515.738\" cy=\"57.1163\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"511.326\" cy=\"60.7185\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"511.326\" cy=\"60.7185\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"492.548\" cy=\"75.9481\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"492.548\" cy=\"75.9481\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"426.585\" cy=\"128.032\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"426.585\" cy=\"128.032\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"430.238\" cy=\"125.208\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"430.238\" cy=\"125.208\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"418.926\" cy=\"133.928\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"418.926\" cy=\"133.928\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"492.548\" cy=\"75.9481\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"492.548\" cy=\"75.9481\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"461.408\" cy=\"100.819\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"461.408\" cy=\"100.819\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"528.395\" cy=\"50.2162\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"528.395\" cy=\"50.2162\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"343.832\" cy=\"194.372\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"343.832\" cy=\"194.372\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"107.188\" cy=\"334.71\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"107.188\" cy=\"334.71\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"110.368\" cy=\"333.452\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"110.368\" cy=\"333.452\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"392.16\" cy=\"158.758\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"392.16\" cy=\"158.758\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"410.705\" cy=\"144.656\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"410.705\" cy=\"144.656\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"234.009\" cy=\"268.143\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"234.009\" cy=\"268.143\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"463.163\" cy=\"103.57\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"463.163\" cy=\"103.57\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"475.055\" cy=\"94.0239\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"475.055\" cy=\"94.0239\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"447.639\" cy=\"115.907\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"447.639\" cy=\"115.907\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"435.824\" cy=\"125.197\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"435.824\" cy=\"125.197\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"477.106\" cy=\"92.3687\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"477.106\" cy=\"92.3687\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"399.134\" cy=\"153.482\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"399.134\" cy=\"153.482\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"334.536\" cy=\"201.023\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"334.536\" cy=\"201.023\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"557.381\" cy=\"25.7688\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"557.381\" cy=\"25.7688\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"412.295\" cy=\"143.436\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"412.295\" cy=\"143.436\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"528.395\" cy=\"50.2162\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"528.395\" cy=\"50.2162\" r=\"3\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"552.47\" cy=\"29.9411\" r=\"4\"/>\n",
       "<circle clip-path=\"url(#clip1202)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"552.47\" cy=\"29.9411\" r=\"3\"/>\n",
       "<polyline clip-path=\"url(#clip1202)\" style=\"stroke:#3da44d; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  66.2381,350.209 112.343,319.86 140.05,301.621 163.476,286.201 188.923,269.45 212.383,254.007 237.535,237.451 266.675,218.268 292.572,201.222 315.281,186.273 \n",
       "  340.04,169.975 364.947,153.58 392.484,135.454 418.684,118.207 445.927,100.274 468.86,85.178 496.858,66.7479 523.177,49.423 565.342,21.6673 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip1200)\" points=\"\n",
       "486.505,93.171 562.315,93.171 562.315,32.691 486.505,32.691 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  486.505,93.171 562.315,93.171 562.315,32.691 486.505,32.691 486.505,93.171 \n",
       "  \"/>\n",
       "<circle clip-path=\"url(#clip1200)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"513.505\" cy=\"47.811\" r=\"6\"/>\n",
       "<circle clip-path=\"url(#clip1200)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"513.505\" cy=\"47.811\" r=\"5\"/>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 534.505, 52.311)\" x=\"534.505\" y=\"52.311\">DF</text>\n",
       "</g>\n",
       "<circle clip-path=\"url(#clip1200)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"513.505\" cy=\"62.931\" r=\"6\"/>\n",
       "<circle clip-path=\"url(#clip1200)\" style=\"fill:#e26f46; stroke:none; fill-opacity:1\" cx=\"513.505\" cy=\"62.931\" r=\"5\"/>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 534.505, 67.431)\" x=\"534.505\" y=\"67.431\">PP</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip1200)\" style=\"stroke:#3da44d; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  492.505,78.051 528.505,78.051 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip1200)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 534.505, 82.551)\" x=\"534.505\" y=\"82.551\">y3</text>\n",
       "</g>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "using StatPlots #need to use StatPlots since we have a DataFrame\n",
    "\n",
    "@df df scatter(:pred_htIE,:pred_htKT,group=:Species,xlabel=\"Predicted Height - IE\",\n",
    "ylabel=\"Predicted Height - KT\")\n",
    "Plots.abline!(1,0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "While a very simplified example, we can start to see how we can swap the parts in and out quickly to accomodate\n",
    "regional forms and others without extensive code refactoring."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.2",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
